package IO流;

import java.io.*;

public class LineNumber {
    //4通过字符缓冲流为文件中的内容添加行号
    public static void main(String[] args) {
        BufferedReader bf = null;
        BufferedWriter bw = null;
        try {
           bf=new BufferedReader(new FileReader("e:/a.txt"));
           bw=new BufferedWriter(new FileWriter("e:/cc.txt"));
           String temp="";
           int i=1;
           while ((temp=bf.readLine())!=null){
               bw.write(i+""+temp);
               bw.newLine();
               i++;

           }
           bw.flush();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (bf != null) bf.close();
                if (bw != null) bw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
